﻿using System;
using GoProtoTest;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Text;
using System.IO;

namespace UdpToolKit2
{
    class Program
    {
        private static UdpClient udpcSend = null;

        static IPEndPoint localIpep = null;
        static void Main(string[] args)
        {
            Console.WriteLine("start");
            UdpClient udpClient = new UdpClient();
            udpClient.Connect("127.0.0.1", 8000);
            int i = 0;
            while (true)
            {
                MsgReq msg = new MsgReq();
                msg.Message = "client";
                msg.Cnt = i++;
                MemoryStream ms = new MemoryStream();
                byte[] sendbytes = new byte[100];
                Google.Protobuf.CodedOutputStream stream = new Google.Protobuf.CodedOutputStream(sendbytes);
                msg.WriteTo(stream);
                // IPEndPoint remoteIpep = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 8000); // 发送到的IP地址和端口号
                udpClient.Send(sendbytes, sendbytes.Length);
            }
        }

    }
}
